<template>
    <div>
        <div class="add" v-for="(list,index) in item" :key="index"> 
            <input type="text" v-model="list.text" :id="index" data-field="date" placeholder="请输入你需要记住的事">
            <van-icon name="add-o" @click="btn(list)"/>
        </div>
    </div>
</template>

<script>

export default {
    name:'add',
    data() {
        return {
            item: [{
                id:"",
                text: ""
            }]
        };
    },
    methods: {
        btn(list) {
            var _this = this;
            var date = new Date();
            var fh1 = "-";
            var fh2 = ":";
            var fh3 = "";
            var year = date.getFullYear(); // 年
            var month = date.getMonth() + 1; // 月
            var day = date.getDate(); // 日
            var hour = date.getHours(); // 时
            var minutes = date.getMinutes(); // 分

            var formatNumber = function (n) {
                n = n.toString()
                return n[1] ? n : '0' + n
            }

            var currentdate = formatNumber(month) + '月' + formatNumber(day) + '日'
            var data = {
                text: list.text,
                currentdate: currentdate
            };

            list.text == "" ? this.$notify({message: '不能提交空值哦',duration: 1000,background: '#1989fa'}):this.$store.dispatch("setOrder", data);
            list.text = "";
            //  this.$router.back();
        }
    }
}
</script>

<style lang="sass" scoped>
@import '../assets/style/common.scss'

.add 
    width: 100%
    height: px2rem(96px)
    background: #32c9ff
    display: flex
    // justify-content: center
    align-items: center
    position: fixed
    z-index: 1

    input 
        width: px2rem(520px)
        height: px2rem(64px)
        border-radius: px2rem(32px)
        padding-left: px2rem(20px)
        margin-left: px2rem(20px)
        background: rgba(225, 225, 225, 0.3)
        color: #fff
        opacity: 0.7
        font-size: px2rem(24px)
    & ::-webkit-input-placeholder 
        color: #fff
        opacity: 0.7

    i 
        font-size: px2rem(64px)
        color: white
        position: absolute
        right: px2rem(20px)
        cursor: pointer
</style>